/* 
	Copyright 2011 David Young. All Rights Reserved. I love you and your poorly commented code unreal <3.
*/

// 9........ <-Number of times I've dropped the f-bomb in my comments.

/*Bitch I don't give two flips about cloning. There's only room for one Joe Macnamara
* in this here game.
* If you want to use his sexy ass player model, you can of course put down a bot
* or a dumb skeletal mesh.
*/

class RDPawn_Player extends RDPawn
	nontransient
	notplaceable;

/*So I was like, writing some code, and then I was all: "Bro, what if wrote retarded stuff just for shits and giggles?". It's not like anyone reads these things. 
 Are you ready for some totally gnarly simulated functions, mondo-mentous commentary, bro-d-alicous event based code, and FUCKING HEALTH CHEATS TO THE EXXXTTREEEEMMMMEEEEEE?
*/



/* This constant modfies the player's stats based on level.   
 *  - 	Remainders are lopped off and only the full values count.
 *  - 	For example: Evaluating (9 [Level] * 0.25 [LevelStatMod]) would yeild 2.33 (infinite remainder). 
 *     That .33 would get cut off and the affected stats would have a 2+ bonus. BTW, .33 is the size of your dick... IN CENTIMETERS. OHHHHHHHH BURRRRNNN.
 
 *  - 	This modifier is used in 'most' level based calculations. Take note that other factors would affect the overall bonus/negation aswell. 
 *  -  All health related values are set at an unmodified static value for added realism. Although, the "SuperHealthMax" value is affected by this modifier.
 */
const LevelStatMod = 0.25;

//Default starting health.
const StartingHealth = 100;
const StartingSuperHealth = 200;

//Variables related to the health system.
var int iHealthRegen;            //Amount of health the player regenerates per regen cycle.
var int iRegenRate; 		        //Rate at which the player regenerates.
var int iMaxHealthRegenAmount;   //Maximum amount the player is allowed to regenerate.

var int iMaxCheatHealth;  		//Health cheat.
var int iLevel;
var bool isUsingHealthCheat;

//The character's information.
var string sFullName;
var string sFirstName;
var string sLastName;
var int iAge;

//Current wounded status. Used for progressive deterioration of player's stats directly proportional to the amount of damage he recieves.
var enum HealthThreshhold
{	
	HEALTHY,			// 75% < Health <= 100%
	FLESHWOUND,		// 50% <= Health <= 75%
	CRITICAL,  			// 25% < Health < 50%              <- This is when the regen kicks in. AW YEEEAAHHH.
	MORTALLY_WOUNDED,	// 0%   < Health <= 25%
	DEAD				// You fucking suck at this game.
} PlayerWoundedStatus;

//Used in tandem with the above to for the already explained reasons. These are short term statuses that can be improved by stopping/walking/resting.
var enum FATIGUE
{
	FRESH,			//Stats possitively affected. Small bonus.
	STRAINED, 		//Stats not affected.
	TIRED,			//Stats slightly affected (negatively).
	EXHAUSTED		//Stats negatively affected. Poor accuracy, etc.
} PlayerFatigueStatus;

//Player's sleepiness status.
var enum RestStatus
{
	WELL_RESTED, 	//Just woke up. Small stat boner.
	NORMAL, 		//Normal status.
	SLEEPY,			//Sleepy, stats negatively affected.
	NEARCOLLAPSE	//Needs sleep now, stats grossly affected. This programmer needs some coffee.
} PlayerRestStatus;


//Self explanitory. Used in combination with HealthThreshHold values to determine the player's ability to walk, etc. This will be assigned to each limb.
enum LimbStatus
{
	HEALTHY,		//Limbs at normal functioning capacity.
	BROKEN			//Limb is broken. Sucks to be you (stats negatively affected). Get the fuck over it and prop it up with some fucking pcp pipe and DUCT TAPE.
};

/**********************************************************************************************
	-Utility and standard functionality.
**********************************************************************************************/

//Returns true if succesful. This enables the health cheat.
exec function ActivateFuckingHealthCheat()
{
	`log("SOFTCORE SOFTCORE SOFTCORE SOFTCORE");
	Health = iMaxCheatHealth;
	isUsingHealthCheat = true;
}

//Disable the health cheat.
exec function DisableFuckingHealthCheat()
{
	if( isUsingHealthCheat)
	{
		`log("I know what you did you dirty whore.");
		Health = HealthMax;
		isUsingHealthCheat = false;
	}
}

//Called when healing past the MaxHealth value.
function int SpecialHeal( int hAmount )
{
	local int newHealth;
	newHealth = Health + hAmount;
	
	if( newHealth > SuperHealthMax )
		return SuperHealthMax;
	else if( newHealth < 0 )
		return 0;
	else
		return newHealth;
}

//PostBeginPlay function. This runs the parent class's function and then runs the timer code. More may be added later. Love David.
simulated function PostBeginPlay()
{
	Super.PostBeginPlay();
	SetTimer(iRegenRate, true);
}

//Regenerating health timer. Modify the outcome of health regeneration with the 3 variables that govern it.
function Timer()
{
	if( Controller.IsA('PlayerController') && !IsInPain() && Health<iMaxHealthRegenAmount)
	{
		Health+=iHealthRegen;
	}
}

/**********************************************************************************************
	- These functions are mostly for updating the client's HUD and other info.
***********************************************************************************************/

//Set both to true if you want to return the player's first and last name. You may choose to not enter parameters and return the first name by default.
simulated function string GetName(optional bool bGetFirst = false, optional bool bGetLast = false )
{
	if( bGetFirst && bGetLast)
		return sFirstName@" "@sLastName;
	else if( bGetLast )
		return sLastName;
	else
		return sFirstName;
}

//Get the player's age.
simulated function int GetAge()
{
	return iAge;
}

//Get the player's level of fatigue (basically like his rest status, but short term and can be improved just by waiting and/or reducing the amount of actions he takes).
simulated function int GetFatigueLevel()
{
	return PlayerFatigueStatus;
}

//Get the player's physical state.
simulated function int GetWoundedStatus()
{
	return PlayerWoundedStatus;
}

//Get the player's state of rest.
simulated function int GetRestStatus()
{
	return PlayerRestStatus;
}

//Get the player's current health.
simulated function int GetHealth()
{
	return Health;
}

//Get the player's maximum standard health.
simulated function int GetMaximumHealth()
{
	return HealthMax;
}

//Get the player's maximum special health (acheivable through temporary items).
simulated function int GetExtendedMaxHealth()
{
	return SuperHealthMax;
}

/**********************************************************************************************
	- States
**********************************************************************************************/

defaultproperties
{ 
	//***********************Overides from up the class heirarchy (sounds like a twilight zone episode).
	
	//Health related defaults.
	HealthMax= StartingHealth				//Standard health maximum.
	Health= StartingHealth					//Seriously, you need me to explain this? Gtfo my code.
	
	//This variable allows for the player's health to be temporarily increased beyond the standard max health by "powerups" such as drugs and what-not. Keep Gage away from the Acid.
	SuperHealthMax= StartingSuperHealth
	
	
	//**********************New defaults (My code is sexier than Unreal's code. Screw you and your multi-thousand line files. COMPONENTS MAN. COMPONENTS.)
	
	//Health regeneration variables.
	iHealthRegen= 1 						//Fuck you Call Of Duty, in this game you don't regen your health all the way. MUAHAHAHAHHAHAHA. Regen Amount per timer tick.
	iRegenRate= 3  				 		//In seconds.
	iMaxHealthRegenAmount= 50			 	//So I herd u liek mudkipz. Is this true? Jk, this is the threshold at which you stop regening.
	
	//Health variables.
	iMaxCheatHealth= 9001 					//OVVVEEERRRRR NNOOOIIINNNN THOOOOWWWWZZZZAAANNNDDDDD. Fucking cheaters. Fuck you softcore gamers.
	isUsingHealthCheat= false
	
	//Character info
	sFirstName= "Joe"
	sLastName= "MacNamara"
	iAge= 24
	
	//Status variables.
	PlayerFatigueStatus= FRESH		    	//Like the prince of Bel-air.
	PlayerWoundedStatus= HEALTHY 			//The opposite of Fidel Castro. I hope you die a horrible and glorious stereotypical communist death.
	PlayerRestStatus= WELL_RESTED 		    //Fallout 3 prostitutes amrite?
	
	//Background stuff.
	
}